import {legacy_createStore,applyMiddleware} from "redux"
import logger from "redux-logger";
import thunk from "redux-thunk"
import {AllTYPES,ALLCKTYPES,SETLIST,ADDLIST} from "../types/store.d"
const initialState = {
    list:[],
    shopcar:[]
}

const reducer=(state:AllTYPES = initialState, { type, payload }:ALLCKTYPES) => {
    switch (type) {

    // case SETLIST:
    //      state.list=payload
    //      return {...state}
    case ADDLIST:
        const newlist=[...state.shopcar]
        newlist.push(payload)
        state.shopcar=newlist
        return {...state}
    default:
        return state
    }
}

const store=legacy_createStore(reducer,applyMiddleware(logger,thunk))
export default store